package cn.zc.curriculum.service.controller.admin;

import cn.tools.core.base.R;
import cn.zc.curriculum.entity.Dto.CurriculumCoursewareDto;
import cn.zc.curriculum.service.service.CurriculumCoursewareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "后台课件管理接口")
@RestController
@RequestMapping("/curriculum")
public class AdminCurriculumCoursewareController {

    @Resource
    private CurriculumCoursewareService curriculumCoursewareService;


    /**
     * 创建课件
     * @param curriculumCoursewareDto
     * @return
     */
    @ApiOperation(value = "创建课件")
    @PostMapping("/admin/create/CurriculumCourseware")
    private R createCurriculumCourseware(@RequestBody CurriculumCoursewareDto curriculumCoursewareDto){
        curriculumCoursewareService.createCurriculumCourseware(curriculumCoursewareDto);
        return R.success();
    }

    /**
     * 查询课件
     * @param menuId
     * @return
     */
    @ApiOperation(value = "查询课件")
    @GetMapping("/admin/find/CurriculumCoursewareByMenu")
    private R<Object> findCurriculumCoursewareByMenu(String menuId){
        List<CurriculumCoursewareDto> courseware = curriculumCoursewareService.findCurriculumCoursewareByMenu(menuId);
        return R.success(courseware);
    }

    /**
     * 修改课件
     * @param curriculumCoursewareDto
     * @return
     */
    @ApiOperation(value = "修改课件,修改都是通过id判定修改那条一定要带id")
    @PutMapping("/admin/update/CurriculumCoursewareByMenu")
    private R updateCurriculumCoursewareByMenu(@RequestBody CurriculumCoursewareDto curriculumCoursewareDto){
        curriculumCoursewareService.updateCurriculumCoursewareByMenu(curriculumCoursewareDto);
        return R.success();
    }


    /**
     * 删除课件
     * @param Id
     * @return
     */
    @ApiOperation(value = "删除课件")
    @DeleteMapping("/admin/delete/CurriculumCoursewareByMenu")
    private R deleteCurriculumCoursewareByMenu(String Id){
        curriculumCoursewareService.deleteCurriculumCoursewareByMenu(Id);
        return R.success();
    }


}
